﻿using System;
using System.Collections.Generic;
using System.Text;
using KKCai.App.Model;
using NHibernate;

namespace KKCai.App.DAL
{
    internal class NewsDao : YN.Core.AbstractDao<NewsInfo>
    {
        internal IList<NewsInfo> ShowByType(int tid, int start, int limit)
        {
            string hql = "from NewsInfo n where n.NewsType.id = ? and n.IsHidden = false order by n.IsTop, n.EditDate desc";

            IQuery q = Session.CreateQuery(hql).SetInt32(0, tid);

            return base.Query(q, start, limit);
        }

        internal int CountByType(int tid)
        {
            string hql = "select count(*) from NewsInfo n where n.NewsType.id = ?";

            IQuery q = Session.CreateQuery(hql).SetInt32(0, tid);

            return base.GetCount(q);
        }
    }
}
